
package com.cptravel.adapter;

import java.util.List;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.core.controller.B5MBaseAdapter;
import com.core.util.B5MBitmapHelper;
import com.cptravel.R;
import com.cptravel.bean.Order;
import com.cptravel.tool.OrderStatus;

public class OrderAdapter extends B5MBaseAdapter<Order>
{
    public OrderAdapter(Activity activity, List<Order> mList)
    {
        super(activity, mList);
        // TODO Auto-generated constructor stub
    }

    @Override
    public View getView(int position , View convertView , ViewGroup parent , ViewHolder viewHolder)
    {
        // TODO Auto-generated method stub
        ImageView iv_pic = viewHolder.obtainView(convertView, R.id.iv_pic);
        TextView tv_no = viewHolder.obtainView(convertView, R.id.tv_order_no);
        TextView tv_product = viewHolder.obtainView(convertView, R.id.tv_order_product);
        TextView tv_money = viewHolder.obtainView(convertView, R.id.tv_order_money);
        TextView tv_datetime = viewHolder.obtainView(convertView, R.id.tv_order_datetime);
        TextView tv_status = viewHolder.obtainView(convertView, R.id.tv_order_status);
        Order order = list.get(position);
        B5MBitmapHelper.displayDefaultNotPeopleRoundImage(order.thum_img, iv_pic);
        tv_no.setText(String.format("订单编号:%s", order.orderid));
        tv_product.setText(String.format("订单商品:%s", order.pname));
        tv_money.setText(String.format("订单金额:%s", Double.valueOf(order.pprice)*Double.valueOf(order.number)));
        tv_datetime.setText(String.format("下单时间:%s", order.createtime));
        tv_status.setText(String.format("订单状态:%s", OrderStatus.getOrderStatusDesc(Integer.valueOf(order.state))));
        return convertView;
    }

    @Override
    public int itemLayoutRes()
    {
        // TODO Auto-generated method stub
        return R.layout.order_item;
    }
}
